package com.maimang.platform.dsp.controller;

import com.maimang.platform.annotation.Log;
import com.maimang.platform.base.BaseController;
import com.maimang.platform.base.Result;
import com.maimang.platform.common.utils.ExcelUtil;
import com.maimang.platform.dsp.entity.FundDailyDetail;
import com.maimang.platform.dsp.service.FundDailyDetailService;
import com.maimang.platform.enums.BusinessType;
import com.maimang.platform.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Rocky
 * @version 1.0.0
 * @classname FundDailyDetailController
 * @description <br>账号流水明细信息操作处理</br>
 * @date 2019-08-05 16:29:06
 * @email jintaozhao@qq.com
 */
@Controller
@RequestMapping("/dsp/fund/detail")
@Api(value = "账号流水明细", description = "账号流水明细 信息操作处理接口")
public class FundDailyDetailController extends BaseController {
	private String prefix = "dsp/fundDailyDetail";

	@Autowired
	private FundDailyDetailService fundDailyDetailService;

	@RequiresPermissions("dsp:fund:view")
	@GetMapping()
	public String fundDailyDetail() {
		return prefix + "/detail";
	}

	/**
	 * 查询账号流水明细列表
	 */
	@ApiOperation(value = "查询列表", notes = "查询账号流水明细列表信息")
	@RequiresPermissions("dsp:fund:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(FundDailyDetail fundDailyDetail) {
		startPage();
		List<FundDailyDetail> list = fundDailyDetailService.selectFundDailyDetailList(fundDailyDetail);
		return getDataTable(list);
	}


	/**
	 * 导出账号流水明细列表
	 */
	@ApiOperation(value = "导出列表", notes = "导出账号流水明细列表信息到Excel文件")
	@RequiresPermissions("dsp:fund:export")
	@PostMapping("/export")
	@ResponseBody
	public Result export(FundDailyDetail fundDailyDetail) {
		List<FundDailyDetail> list = fundDailyDetailService.selectFundDailyDetailList(fundDailyDetail);
		ExcelUtil<FundDailyDetail> util = new ExcelUtil<FundDailyDetail>(FundDailyDetail.class);
		return util.exportExcel(list, "fundDailyDetail");
	}

	/**
	 * 新增账号流水明细
	 */
	@GetMapping("/add")
	public String add() {
		return prefix + "/add";
	}

	/**
	 * 新增保存账号流水明细
	 */
	@ApiOperation(value = "新增保存", notes = "参数：FundDailyDetail")
	@RequiresPermissions("dsp:fund:add")
	@Log(title = "账号流水明细", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public Result addSave(FundDailyDetail fundDailyDetail) {
		return toResult(fundDailyDetailService.insertFundDailyDetail(fundDailyDetail));
	}

	/**
	 * 修改账号流水明细
	 */
	@GetMapping("/edit/{advertiserId}")
	public String edit(@PathVariable("advertiserId") int advertiserId, ModelMap modelMap) {
		FundDailyDetail fundDailyDetail = fundDailyDetailService.selectFundDailyDetailById(advertiserId);
		modelMap.put("fundDailyDetail", fundDailyDetail);
		return prefix + "/edit";
	}

	/**
	 * 修改保存账号流水明细
	 */
	@ApiOperation(value = "修改保存", notes = "参数：FundDailyDetail")
	@RequiresPermissions("dsp:fund:edit")
	@Log(title = "账号流水明细", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public Result editSave(FundDailyDetail fundDailyDetail) {
		return toResult(fundDailyDetailService.updateFundDailyDetail(fundDailyDetail));
	}

	/**
	 * 删除账号流水明细
	 */
	@ApiOperation(value = "删除对象", notes = "参数：ids，示例： id1,id2,id3，接口会转转为String[]类型")
	@RequiresPermissions("dsp:fund:remove")
	@Log(title = "账号流水明细", businessType = BusinessType.DELETE)
	@PostMapping("/remove")
	@ResponseBody
	public Result remove(String ids) {
		return toResult(fundDailyDetailService.deleteFundDailyDetailByIds(ids));
	}

}